Documentation > CMS Template API Library > Asset > GetDateOverlap(DateTime,DateTime,String,String,Boolean,List[String],Boolean)
GetDateOverlap
Gets a List of Assets from the CMS that contain a date range which overlaps the specified range.
public List<Asset> GetDateOverlap(DateTime,DateTime,String,String,Boolean,List[String],Boolean)
Returns
A List of matching Assets.
Parameters
Name | Description | Type |
---|---|---|
startDate | The minimum of the date range. | System.DateTime |
endDate | The maximum of the date range. | System.DateTime |
startField | The name of the asset field which contains the start of its date range. | System.String |
endField | The name of the asset field which contains the end of its date range. | System.String |
isRecursive | (Optional) If true, subfolders will also be searched. If false, only the folder specified will be searched. Defaults to false. | System.Boolean |
filterStatus | (Optional) The list of states to filter on, if any. Defaults to the context's filter status. | List<String> |
excludeProjectTypes | (Optional) if true excludes special asset types that are related to projects like libraries and templates from appearing in the results. Defaults to true. | System.Boolean |
Code Example
C#
Sample:
// Assume the assets that we are trying to pull in have startdate and enddate fields. // If the following dates overlap startdate and enddate in any way, asset will be retrieved. DateTime startDT = new DateTime(2019, 12, 22); DateTime endDT = new DateTime(2019, 12, 25); // The folder to search Asset searchFolder = asset.Parent; if(searchFolder.IsLoaded) { List<Asset> list = searchFolder.GetDateOverlap(startDT, endDT, "startdate", "enddate"); foreach(Asset a in list) { Out.WriteLine("ID: " + a.Id + " - " + a.AssetPath.ToString() + " - " + a["startdate"] + " - " + a["enddate"] + "<br />"); } }